﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace OrderAggregator.UI
{
    public class BaseEditListControl : UserControl
    {
        private bool _readOnly = false;

        public bool ReadOnly
        {
            get
            {
                return _readOnly;
            }
            set
            {
                if (_readOnly != value)
                {
                    _readOnly = value;

                    OnReadOnlyChanged();
                }
            }
        }

        public virtual DataRow SelectedRow
        {
            get; set;
        }

        public event EventHandler SelectedRowChanged;

        public virtual void SaveChanges()
        {
        }

        protected void RaiseSelectedRowChanged()
        {
            if (SelectedRowChanged != null)
            {
                SelectedRowChanged(this, EventArgs.Empty);
            }
        }

        protected virtual void OnReadOnlyChanged()
        {
        }
    }
}
